Base solution for your next web application

Activities of "hans abelshausen"

No, I haven't a test package included. Only Abp.Zero version 6.0.3.4 but Abp.TestBase.Runtime.Session.TestAbpSession as Session. Is the TestAbpSession included in the abp.zero package?

This is also an error of my login: Failed to load resource: the server responded with a status of 500 (Internal Server Error) Perhaps it is the same problem described here: [http://forum.aspnetboilerplate.com/viewtopic.php?f=3&t=214])

I can't find the test package. I have added the Abp.Zero version 0.6.3.4 Strange...

I have updated to newest version of Abp.Zero and if I check the loginAsync function, there is a difference between my solution and yours. the castle.proxies.usermanagerproxy base AbpSession is Abp.TestBase.Runtime.Session.TestAbpSession in your code it is Abp.Runtime.Session.AbpSession Is this perhaps the problem? Where can I change it?

Yes, I have copied your code, here it is: (in my loginresult.User there is an error: internal error in method "Abp.Authorization.Users.AbpUserManager'3#AbpLoginResult[TTenant, TRole, TUser].get_user()")

using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Abp.Authorization.Users;
using Abp.UI;
using Abp.Web.Mvc.Models;
using Microsoft.AspNet.Identity;
using Microsoft.Owin.Security;
using Test.Security.Users;
using Test.Web.Models.Account;


namespace Test.Web.Controllers
{
    public class AccountController : TestControllerBase
    {
        private readonly UserManager _userManager;

        private IAuthenticationManager AuthenticationManager
        {
            get
            {
                return HttpContext.GetOwinContext().Authentication;
            }
        }

        public AccountController(UserManager userManager)
        {
            _userManager = userManager;
        }

        public ActionResult Login(string returnUrl = "")
        {
            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }

            ViewBag.ReturnUrl = returnUrl;

            return View();
        }

        [HttpPost]
        public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                throw new UserFriendlyException("Your form is invalid!");
            }

            var loginResult = await _userManager.LoginAsync(
                loginModel.UsernameOrEmailAddress,
                loginModel.Password,
                loginModel.TenancyName
                );

            
            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    break;
                case AbpLoginResultType.InvalidUserNameOrEmailAddress:
                case AbpLoginResultType.InvalidPassword:
                    throw new UserFriendlyException("Invalid user name or password!");
                case AbpLoginResultType.InvalidTenancyName:
                    throw new UserFriendlyException("No tenant with name: " + loginModel.TenancyName);
                case AbpLoginResultType.TenantIsNotActive:
                    throw new UserFriendlyException("Tenant is not active: " + loginModel.TenancyName);
                case AbpLoginResultType.UserIsNotActive:
                    throw new UserFriendlyException("User is not active: " + loginModel.UsernameOrEmailAddress);
                case AbpLoginResultType.UserEmailIsNotConfirmed:
                    throw new UserFriendlyException("Your email address is not confirmed!");
                default: //Can not fall to default for now. But other result types can be added in the future and we may forget to handle it
                    throw new UserFriendlyException("Unknown problem with login: " + loginResult.Result);
            }

            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = loginModel.RememberMe }, loginResult.Identity);

            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }
            
            return Json(new MvcAjaxResponse 
            { 
                TargetUrl = returnUrl
            });
            //return Json(new MvcAjaxResponse 
            //{ 
            //    TargetUrl = returnUrl
            //    //TargetUrl = "/#/"
            //});
        }

        public ActionResult Logout()
        {
            AuthenticationManager.SignOut();
            return RedirectToAction("Login");
        }
    }
}

It seems user is not logged in, but I don't know what is different in my Project... Here is the log file:

DEBUG 2015-06-08 11:16:56,063 [1 ] Abp.Localization.LocalizationManager - Initializing 4 localization sources. DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Abp DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpZero DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb DEBUG 2015-06-08 11:16:57,992 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Test WARN 2015-06-08 11:16:58,315 [10 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) WARN 2015-06-08 11:17:15,594 [12 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext)

I'm using Abp 0.6.2.0 Abp Zero 0.6.0.0

Yes, I have copied the code of your sample Project and the login page is shown, then I took username admin and your Password. In Accountcontroller loginResult is success but this code is never reached:

[AbpMvcAuthorize]
    public class HomeController : MyProjectControllerBase
    {
        public ActionResult Index()
        {
            return View("~/App/Main/views/layout/layout.cshtml"); 
        }
    }
Showing 11 to 17 of 17 entries